#!/usr/bin/env node

const fs = require('fs');
const src = process.argv[2],
      lnk = process.argv[3];

//fs.linkSync(src,lnk);硬链接，源文件删除，链接文件不受影响，可以继续执行
fs.symlinkSync(src,lnk);//软连接，源文件删除，链接文件也不会执行

/*
const fs  = require('fs'),
      err = console.error;

let opt = {
    '4': createhardLink,
    '5': createSoftLink

};
function createSoftLink() {
    let opt = process.argv[2],
        src = process.argv[3],
        lnk = process.argv[4];
    if(opt === '-s') {
      try {
          fs.symlinkSync(src, lnk);                
      } catch(e) {
          err(e.message);
          process.exit(2);                   
      }    
    } else {
          err('命令行参数不正确！');           
    }
}

function createhardLink() {
    let src = process.argv[2],
        lnk = process.argv[3];
    try {
      fs.linkSync(src, lnk);    
    } catch(e) {
      err(e.message);
      process.exit(1);               
    }
}
try {
    opt[process.argv.length]();
} catch(e) {
    err('命令行参数不正确！');
    process.exit(3);
}*/
